home *** CD-ROM | disk | FTP | other *** search
- /*
- ** GETPRO.C
- **
- ** This program downloads PRODUCTS.TXT from our FTP site at
- ** ftp://ftp.marshallsoft.com/marshallsoft/other/products.txt
- **
- ** Change PASSWORD (line 23) to your password before compiling.
- */
-
- #include <windows.h>
- #include <winsock.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <ctype.h>
- #include "fce.h"
-
- #define SRVR_NAME "ftp.marshallsoft.com"
- #define USER_NAME "anonymous"
- #define PASSWORD "msc@traveller.com"
- #define DIRECTORY "msc/other"
- #define FILE_NAME "products.txt"
-
- char Temp[51];
-
- /* globals */
-
- void ShowError(int Code)
- {Temp[0] = '\0';
- fceErrorText(0,Code,(LPSTR)Temp,50);
- printf("ERROR %d: %s\n", Code, Temp);
- }
-
- void ErrorExit(int Code)
- {ShowError(Code);
- fceRelease();
- exit(1);
- }
-
- void main(int argc, char *argv[])
- {int Code;
- ULONG ByteCount;
- int Version;
- int Build;
- /* check arguments */
- if(argc!=1)
- {printf("Usage: GETPRO\n");
- exit(1);
- }
- printf("GETPRO 02/05/99\n");
- printf("Server : %s\n", SRVR_NAME);
- printf(" User : %s\n", USER_NAME);
- printf(" Pass : %s\n", PASSWORD);
- printf(" Dir : %s\n", DIRECTORY);
- printf(" File : %s\n", FILE_NAME);
- printf("\nDownloading %s/%s/%s\n",SRVR_NAME,DIRECTORY,FILE_NAME);
- /* attach FCE */
- Code = fceAttach(1);
- if(Code<0) ErrorExit(Code);
- Version = fceGetInteger(0,FCE_GET_VERSION);
- Build = fceGetInteger(0,FCE_GET_BUILD);
- printf("FCE32 Version: %1d.%1d.%1d Build %d\n",
- 0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version,Build);
- fceGetString(0,FCE_GET_REGISTRATION,(LPSTR)Temp,50);
- printf(" Registration: %s\n", Temp);
- /* define LOG file */
- fceSetString(0,FCE_SET_LOG_FILE,(LPSTR)"getpro.log");
- /* connect to server */
- printf("Connecting...");
- Code = fceConnect(0,(LPSTR)SRVR_NAME,(LPSTR)USER_NAME,(LPSTR)PASSWORD);
- if(Code<0) ErrorExit(Code);
- printf("OK\n");
- /* change to proper directory */
- Code = fceSetServerDir(0, (LPSTR)DIRECTORY);
- if(Code<0) ErrorExit(Code);
- /* set to ASCII xfer mode */
- fceSetMode(0,'A');
- /* download the file */
- printf("Please wait while file %s is being downloaded...\n",FILE_NAME);
- Code = fceGetFile(0,(LPSTR)FILE_NAME);
- if(Code<0) ErrorExit(Code);
- /* display final count */
- ByteCount = fceGetInteger(0, FCE_GET_FILE_BYTES_RCVD);
- printf("%d bytes received\n",ByteCount);
- /* QUIT */
- fceClose(0);
- fceRelease();
- }
-
-